#include "StdAfx.h"
#include "MidiPlayer.h"


MidiPlayer::MidiPlayer(char * _filePath)
:filePath(_filePath)
{
}

MidiPlayer::~MidiPlayer(void)
{
}

void MidiPlayer::play()
{
	rs=new MIDIFileReadStreamFile( filePath );
	tracks=new MIDIMultiTrack( 64 );
	track_loader=new MIDIFileReadMultiTrack  ( tracks );
	reader=new MIDIFileRead  ( rs, track_loader );
	gui=new MIDISequencerGUIEventNotifierText  ( stdout );
	seq=new MIDISequencer  ( tracks, gui );
	driver=new MIDIDriverWin32  ( 128 );
	mgr=new MIDIManager  ( driver, gui );
	reader->Parse();
	driver->StartTimer ( 20 );
	driver->OpenMIDIOutPort ( MIDI_MAPPER );
	seq->GoToZero();
	mgr->SetSeq ( seq );
	mgr->SetTimeOffset ( timeGetTime() );
	mgr->SeqPlay();
}
